//
//  ByCellScroeBillListItem.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/24.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByCellScroeBillListItem.h"

@implementation ByCellScroeBillListItem
{
    UIImageView *_iconView;
    UILabel     *_reasonLabel;
    UILabel     *_timeLabel;
    UILabel     *_amountLabel;

}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    // 线条
    UIView *line = [UIView new];
    line.backgroundColor = BY_LINE_COLOR;
    [self.contentView addSubview:line];

    // 图标
    _iconView = [UIImageView new];
    _iconView.image = [UIImage imageWithColor:[UIColor redColor]];
    [self.contentView addSubview:_iconView];
    
    // 数量图标
    UIImageView *amountIconView = [UIImageView new];
    amountIconView.image = [UIImage imageWithColor:[UIColor redColor]];
    [self.contentView addSubview:amountIconView];
    
    // 数量
    _amountLabel = [[UILabel alloc] init];
    _amountLabel.text = @"+200";
    _amountLabel.font = FONT(20);
    _amountLabel.textAlignment = NSTextAlignmentRight;
    _amountLabel.textColor = BY_GOLD_COLOR;
    [self.contentView addSubview:_amountLabel];
    
    
    // 原因
    _reasonLabel = [[UILabel alloc] init];
    _reasonLabel.numberOfLines = 1;
    _reasonLabel.text = @"家电超市积分转换";
    _reasonLabel.font = FONT(16);
    _reasonLabel.textAlignment = NSTextAlignmentLeft;
    _reasonLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:_reasonLabel];
    
    // 原因
    _timeLabel = [[UILabel alloc] init];
    _timeLabel.adjustsFontSizeToFitWidth = true;
    _timeLabel.numberOfLines = 1;
    _timeLabel.text = @"2012-12-08 22:22";
    _timeLabel.font = FONT(15);
    _timeLabel.textAlignment = NSTextAlignmentLeft;
    _timeLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_timeLabel];
    
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.right.equalTo(@(-10));
        make.bottom.equalTo(@0);
        make.height.equalTo(@1);
    }];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(self.mas_height).multipliedBy(0.6);
        make.left.equalTo(line);
        make.centerY.equalTo(self);
    }];
    [amountIconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(20, 20));
        make.right.equalTo(self).offset(-10);
        make.centerY.equalTo(self);
    }];
    [_amountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(amountIconView.mas_left).offset(-5);
        make.top.height.equalTo(self);
    }];
    [_reasonLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_iconView.mas_right).offset(10);
        make.height.equalTo(_iconView).multipliedBy(0.5);
        make.top.equalTo(_iconView);
        make.right.lessThanOrEqualTo(_amountLabel.mas_left).offset(-10);
    }];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_reasonLabel);
        make.height.equalTo(_reasonLabel);
        make.bottom.equalTo(_iconView);
        make.right.lessThanOrEqualTo(_amountLabel.mas_left).offset(-10);
    }];
    
}
- (void)setAmountColor:(UIColor *)amountColor {
    
    _amountColor = amountColor;
    _amountLabel.textColor = amountColor;
}



@end
